{include file='Public/header' /}
<div class="layui-layout layui-layout-admin">
{include file='Public/head' /}	
{include file='Public/side' /}	
	<div class="layui-body"> 
{include file='Public/crumbs' /}
		<!-- 内容主体区域 -->
		<div class="shu-body">
			<div class="layui-fluid">
				<form class="layui-form layui-form-pane" action="" method="post">
				<input name="id" value="{notempty name='currentmenu'}{$currentmenu.id}{/notempty}" type="hidden">
				<div class="layui-form-item">
					<label class="layui-form-label">上级菜单</label>
				  	<div class="layui-input-block">
					<select id="pid" name="pid" lay-verify="required">
						<option value="0"
						{notempty name='currentmenu'}
						{if condition="$currentmenu.pid eq 0"}selected="selected"{/if}
						{/notempty}
						>顶级菜单</option>
						{volist name="option" id="v"}
							<option value="{$v.id}"
								{notempty name='currentmenu'}
							{if condition="$currentmenu.pid eq $v['id']"}selected="selected"{/if}
							{/notempty}
							>{$v['title']}</option>
							{notempty name='v.children'}
							{volist name="v.children" id="vv"}
								<option value="{$vv.id}"
								{notempty name='currentmenu'}
								{if condition="$currentmenu.pid eq $vv['id']"}selected="selected"{/if}
								 {/notempty}
								>&nbsp;&nbsp;┗━{$vv['title']}</option>
							{/volist}
							{/notempty}
						{/volist}
					</select>
				    </div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">菜单名称</label>
				  	<div class="layui-input-block">
					<input type="text" name="title" id="title" value="{notempty name='currentmenu'}{$currentmenu.title}{/notempty}" required lay-verify="required" autocomplete="off" class="layui-input">
				  	</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">链接</label>
				  	<div class="layui-input-block">
					<input type="text" name="name" id="name" placeholder="链接，如：Index/index" class="layui-input" value="{notempty name='currentmenu'}{$currentmenu.name}{/notempty}" class="layui-input">
				  	</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">传参值</label>
				  	<div class="layui-input-block">
					<input type="text" name="cs" id="cs" placeholder="只能数字" class="layui-input" value="{notempty name='currentmenu'}{$currentmenu.cs}{/notempty}" class="layui-input" onKeyUp="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
				  	</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">ICON图标</label>
				  	<div class="layui-input-inline">
					<input type="text" name="icon" id="icon" placeholder="ICON图标" class="layui-input" value="{notempty name='currentmenu'}{$currentmenu.icon}{else /}menu-icon fa fa-desktop{/notempty}" class="layui-input">
				  	</div>
					<div class="layui-form-mid layui-word-aux">menu-icon fa fa-desktop</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">显示状态</label>
				  	<div class="layui-input-block">
						<input type="checkbox"
						{notempty name='currentmenu'}
                        {if condition="$currentmenu.islink eq 1"}checked="checked"{/if}
                        {/notempty}
						name="islink" id="islink" lay-skin="switch" lay-text="显示|隐藏" lay-filter="switchTest" value="1"><div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>隐藏</em><i></i></div>
				 	</div>
				</div>
				<div class="layui-form-item">
				  	<label class="layui-form-label">排序</label>
				  	<div class="layui-input-inline">
					<input type="text" name="o" id="o" placeholder="排序" class="layui-input" value="{notempty name='currentmenu'}{$currentmenu.o}{/notempty}" class="layui-input" onKeyUp="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
				  	</div>
					<div class="layui-form-mid layui-word-aux">数字越大越靠前</div>
				</div>
				<div class="layui-form-item layui-form-text">
				  <label class="layui-form-label">页面提示</label>
				  <div class="layui-input-block">
					<textarea name="tips" id="tips" placeholder="页面提示" class="layui-textarea">{notempty name='currentmenu'}{$currentmenu.tips}{/notempty}</textarea>
				  </div>
				</div>
				<div class="layui-form-item">
				  <div class="layui-input-block">
					<button class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				  </div>
				</div>
			  </form>
			</div>
		</div>
		<!-- 内容主体区域 END-->
	</div>
{include file='Public/footer' /}	
<script>
layui.use(['form','layer'], function(){
	var form = layui.form,jq = layui.jquery,layer=layui.layer;
	form.on('submit(formDemo)', function(data){
		loading = layer.load(2, {
			shade: [0.2,'#000']
		});
		var param = data.field;
		jq.post("{:url('update')}",param,function(data){
			//console.log(data);
			if(data.code == 200){
				layer.close(loading);
				layer.msg(data.msg, {icon: 1, time: 1000}, function(){
					//location.reload();
					location.href="{:url('index')}";
				});
			}else{
				layer.close(loading);
				layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
			}
		});
	return false;
	});
});
</script>